import java.io.File;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要搜索的目录路径：");
        String path = scanner.next();

        File file = new File(path);
        if(file.isFile() && file.exists()){
            System.out.println(file.getAbsolutePath());
        }else{
            Listname(file);
        }
    }

    public static  void Listname(File file){
        if(file.isFile() && file.exists()){
            System.out.println(file.getAbsolutePath());
        }else{
            File[] files = file.listFiles();
            if (files != null) {
                for(File file1:files){
                    Listname(file1);
                }
            }else{
                System.out.println("该路径不存在");
            }
        }
    }
}
